﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace FierceWar
{
	public class CreateMapOptionScreen : MenuScreen
	{
		private MenuEntriesManager _menuEntriesManager;
		private MenuEntry _createNewMap;
		private MenuEntry _editMap;
		private MenuEntry _back;

		
		private Rectangle _outerRectangle;
		private Rectangle _innerRectangle;

		public CreateMapOptionScreen(GameResources resources,
			List<EventHandler> screenEvents)
			: base(resources, screenEvents)
		{
			_createNewMap = new MenuEntry(resources, "Create New Map", 1500.0f, 100.0f);
			_editMap = new MenuEntry(resources, "Edit An Existing Map", 800.0f, 100.0f);
			_back = new MenuEntry(resources, "Back", 0.0f, 0.0f);

			_menuEntriesManager = new MenuEntriesManager(resources, screenEvents);
			_menuEntriesManager.MenuEntries.Add(_createNewMap);
			_menuEntriesManager.MenuEntries.Add(_editMap);
			_menuEntriesManager.MenuEntries.Add(_back);
			_menuEntriesManager.OriginY = 200.0f;
			_menuEntriesManager.DistanceInterval = 50.0f;
			_menuEntriesManager.InitializePositions();

			
			_outerRectangle = new Rectangle(
				   (Resources.GraphicsDevice.Viewport.Width - 500) / 2,
				   (Resources.GraphicsDevice.Viewport.Height - 200) / 2 - 25,
				   500, 200);
			_innerRectangle = new Rectangle(
					(Resources.GraphicsDevice.Viewport.Width - 480) / 2,
					(Resources.GraphicsDevice.Viewport.Height - 180) / 2 - 25,
					480, 180);
		}

		public override void Update(GameTime gameTime)
		{
			base.Update(gameTime);

			_menuEntriesManager.Update(gameTime);
		}

		
		public override void Draw(GameTime gameTime)
		{
			base.Draw(gameTime);
			Resources.SpriteBatch.Draw(Resources.BackgroundTexture,
				FullScreen, Color.White);
			Resources.SpriteBatch.Draw(Resources.BlankTexture,
				_outerRectangle,
				Color.Black * 0.35f);
			Resources.SpriteBatch.Draw(Resources.BlankTexture,
				_innerRectangle,
				Color.Black * 0.35f);
			_menuEntriesManager.Draw();
		}
	}
}
